import dashboard from "./modules/dashboard";
import editor from "./modules/editor";
import BasicLayout from "@/layouts/basic-layout";

/**
 * 在主框架内显示
 */

const frameIn = [
  {
    path: "/",
    redirect: {
      name: "login",
    },
    component: BasicLayout,
    children: [
      {
        path: "index",
        name: "index",
        redirect: {
          name: "dashboard-console",
        },
      },
      {
        path: "log",
        name: "log",
        meta: {
          title: "前端日志",
          auth: true,
        },
        component: () => import("@/pages/system/log"),
      },
      {
        path: "/setting/user",
        name: "user",
        meta: {
          title: "用户信息",
          cache: false,
        },
        component: () => import("@/pages/system/user"),
      },
      // 刷新页面 必须保留
      {
        path: "refresh",
        name: "refresh",
        hidden: true,
        component: {
          beforeRouteEnter(to, from, next) {
            next((instance) => instance.$router.replace(from.fullPath));
          },
          render: (h) => h(),
        },
      },
      // 页面重定向 必须保留
      {
        path: "redirect/:route*",
        name: "redirect",
        hidden: true,
        component: {
          beforeRouteEnter(to, from, next) {
            next((instance) =>
              instance.$router.replace(JSON.parse(from.params.route))
            );
          },
          render: (h) => h(),
        },
      },
    ],
  },
  {
    path: "/enterpriseInforManage",
    component: BasicLayout,
    children: [
      // 企业信息详情
      {
        path: "/enterpriseInforDetail",
        name: "enterpriseInforDetail",
        meta: {
          title: "企业信息详情",
          auth: true,
        },
        component: () =>
          import("@/pages/enterpriseInforManage/enterpriseInforInquiry/detail"),
      },
      // 企业信息详情
      {
        path: "/changeRecordDetail",
        name: "changeRecordDetail",
        meta: {
          title: "企业信息详情",
          auth: true,
        },
        component: () =>
          import(
            "@/pages/enterpriseInforManage/enterpriseInforInquiry/changeRecordDetail"
          ),
      },
      // 企业信息详情
      {
        path: "/changeRecord",
        name: "changeRecord",
        meta: {
          title: "企业信息变更历史记录",
          auth: true,
        },
        component: () =>
          import(
            "@/pages/enterpriseInforManage/enterpriseInforInquiry/changeRecord"
          ),
      },
    ],
  },
  {
    path: "/enterpriseInforManage",
    component: BasicLayout,
    children: [
      // 企业信息审核详情
      {
        path: "/enterpriseDetail",
        name: "enterpriseDetail",
        meta: {
          title: "企业信息审核详情",
          auth: true,
        },
        component: () =>
          import(
            "@/pages/enterpriseInforManage/enterpriseInforExamine/enterpriseDetail.vue"
          ),
      },
      // 企业信息审核详情
      {
        path: "/changeBeforeAfter",
        name: "changeBeforeAfter",
        meta: {
          title: "企业信息变更记录",
          auth: true,
        },
        component: () =>
          import(
            "@/pages/enterpriseInforManage/enterpriseInforInquiry/changeBeforeAfter.vue"
          ),
      },
    ],
  },
  {
    path: "/businessInformationTracking",
    component: BasicLayout,
    children: [
      {
        path: "/businessInfoWarningDetails",
        name: `businessInfoWarningDetails`,
        meta: {
          title: "经营信息预警详情",
          closable: true,
        },
        component: () =>
          import(
            "@/pages/businessInformationTracking/businessInformationWarning/businessInfoWarningDetails"
          ),
      },
    ],
  },
  {
    path: "/businessInformationTracking",
    component: BasicLayout,
    children: [
      {
        path: "/businessInfoTrackDetails",
        name: `businessInfoTrackDetails`,
        meta: {
          title: "经营信息跟踪详情",
          closable: true,
        },
        component: () =>
          import(
            "@/pages/businessInformationTracking/businessInformationMap/businessInfoTrackDetails"
          ),
      },
    ],
  },
  dashboard,
  editor,
];

/**
 * 在主框架之外显示
 */

const frameOut = [
  // 登录
  {
    path: "/login",
    name: "login",
    meta: {
      title: "$t:page.login.title",
    },
    component: () => import("@/pages/account/login"),
  },{
    path: "/oldlogin",
    name: "oldlogin",
    meta: {
      title: "$t:page.login.title",
    },
    component: () => import("@/pages/account/login/index_old.vue"),
  },
  // 注册
  {
    path: "/register",
    name: "register",
    meta: {
      title: "$t:page.register.title",
    },
    component: () => import("@/pages/account/register"),
  },
  // 注册结果
  {
    path: "/register/result",
    name: "register-result",
    meta: {
      auth: true,
      title: "注册结果",
    },
    component: () => import("@/pages/account/register/result"),
  },
  {
    path: "/retrievePassword",
    name: `retrievePassword`,
    meta: {
      meta: {
        auth: true,
        title: "找回密码",
      },
      title: "找回密码",
      closable: false,
    },
    component: () => import("@/pages/account/retrievePassword"),
  },
];

/**
 * 错误页面
 */

const errorPage = [
  {
    path: "/403",
    name: "403",
    meta: {
      title: "403",
    },
    component: () => import("@/pages/system/error/403"),
  },
  {
    path: "/500",
    name: "500",
    meta: {
      title: "500",
    },
    component: () => import("@/pages/system/error/500"),
  },
  {
    path: "*",
    name: "404",
    meta: {
      title: "404",
    },
    component: () => import("@/pages/system/error/404"),
  },
];

// 导出需要显示菜单的
export const frameInRoutes = frameIn;

// 重新组织后导出
export default [...frameIn, ...frameOut, ...errorPage];
